import Types from '../actionTypes';
import {
  getRefundLsit,
  getInvoiceInfo,
  getOrderDetais, receivingList
} from '../../api';

/**
 *
 * @param page
 * @returns {Function}
 * @constructor
 */
const GET_REFUND_LIST = (page) => {
  return new Promise((resolve, reject) => {
    getRefundLsit(page).then(res => {
      console.log(res);
      resolve({
        type: Types.GET_REFUND_LIST,
        data: res
      });
    }).catch(err => {
      console.log(err);
    });
  });
};
/**
 *
 * @param invoice_id
 * @returns {Promise<unknown>}
 * @constructor
 */
const GET_INVOICE_INFO = invoice_id => {
  return new Promise((res, rej) => {
    getInvoiceInfo(invoice_id).then(data => {
      console.log('***********************************', data);
      res({
        type: Types.GET_INVOICE_INFO,
        data: data.data
      });
    }).catch(err => {
      console.log(err);
    });
  });
};

const GET_ORDER_DETAILS = order_no => {
  return new Promise((res, rej) => {
    getOrderDetais(order_no).then(data => {
      res({
        type: Types.GET_ORDER_DETAILS,
        data: data.data
      });
    }).catch(err => {
      console.log(err);
    });
  });
};

export default {
  GET_REFUND_LIST,
  GET_INVOICE_INFO,
  GET_ORDER_DETAILS
};
